package com.github.prontera.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.github.prontera.ApiVersion;
import com.github.prontera.RequestLogging;
import com.github.prontera.common.filter.CurrentUserId;
import com.github.prontera.domain.ClientRent;
import com.github.prontera.model.request.RentRequest;
import com.github.prontera.model.response.ObjectDataResponse;
import com.github.prontera.service.ClientRentService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;


/**
 * 达人出租
 */
@RestController
@Api(value = "达人出租")
@RequestMapping(value = ApiVersion.API_V1_PREFIX+"/rent")
public class ClientRentController{

	@Autowired
	private ClientRentService clientRentService;
	
	/**
	 * 查询用户达人出租标签
	 */
	@ApiOperation(value = "查询用户达人出租标签",notes = "查询用户达人出租标签")
	@RequestMapping(value = "find", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<List<ClientRent>> find(@ApiParam(hidden=true,name="登录用户ID")@CurrentUserId Long clientId,@RequestBody ClientRent clientRent){
		if(clientRent.getClientId()==null){
			clientRent.setClientId(clientId);
		}
		clientRent.setAuditStatus(1);
		clientRent.setStatus(1);
		List<ClientRent> datas=clientRentService.find(clientRent);
		return new ObjectDataResponse<List<ClientRent>>(datas);
	}
	
	/**
	 * 查询用户达人出租标签
	 */
	@RequestLogging
	@ApiOperation(value = "添加/修改用户达人出租标签",notes = "添加/修改用户达人出租标签")
	@RequestMapping(value = "add", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<Boolean> add(@ApiParam(hidden=true,name="登录用户ID")@CurrentUserId Long clientId,@RequestBody  RentRequest rentRequest){
		clientRentService.insert(rentRequest, clientId);
		return new ObjectDataResponse<Boolean>(true);
	}

}
